package com.frinder.netty;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by kiktech on 2017/8/5.
 */
@Slf4j
@Component
public class NettyStarter implements CommandLineRunner {

    @Autowired
    private NettyServer nettyServer;

    @PostConstruct
    public void before() {
        log.info("Before start!");
    }

    @Override
    public void run(String... strings) throws Exception {
        nettyServer.start();
    }

    @PreDestroy
    public void after() {
        log.info("Destroy!");
        nettyServer.destroy();
    }


}
